#{extends 'main.html' /}
#{set title:'首页' /}

<style>
    .page{ background: #0abe74;}
</style>
<script type="text/javascript" src="/public/sui/js/lrz.all.bundle.js"></script>
<script type="text/javascript" src="/public/sui/js/uploadImgRegist.js"></script>
<script type="text/javascript" src="/public/sui/js/list.js"></script>

<body>
<div class="page-group">
    <div class="page">
        <div class="reg scroll_y">
        	<div class="toptel"><a href="#"><i class="iconfont"></i>注册商户前请先在购物中心绑定手机号</a></div>
        	*{<h3>注册认证</h3>}*
          <form>
            <ul>
              <li>

                <div class="content-block uploadPic">
                    <h3 style="color:#000000">上传Logo</h3>
                    <input type="file" accept="image/*" id="cameraInput" name="cameraInput" style="display:none;"/>
                    <input type="file" accept="image/*" id="cameraInput_andriod" name="cameraInput_andriod"
                           style="display:none;"/>
                    <ul>
                        <li id="addli" class="add create-actions"><img src="/public/sui/images/icon_add2.gif"></li>
                    </ul>
                </div></li>
              <li><input type="text" id="mercahnt_name" class="editbox radius5" placeholder="商户名称" value="" /></li>
              <li><input type="text" id="mercahnt_person" class="editbox radius5" placeholder="联系人" value="" /></li>
              <li><input type="text" id="person_phone" class="editbox radius5" placeholder="手机号" spellcheck="false" tabindex="1" value="" /></li>
                <li><input type="text" id="real_name" class="editbox radius5" placeholder="真实姓名" value="" /></li>
                <li><input type="text" id="we_chat" class="editbox radius5" placeholder="微信号" value="" /></li>
                <li><input type="text" id="teacher" class="editbox radius5" placeholder="指导教师" value="" /></li>
                <li><input type="text" id="classes" class="editbox radius5" placeholder="班级" value="" /></li>
                <li><input type="text" id="team" class="editbox radius5" placeholder="团队名称" value="" /></li>
                <li><input type="text" id="address" class="editbox radius5" placeholder="商户地址" value="" /></li>
              <li><input type="text" id="login_name" class="editbox radius5" placeholder="登录名" value="" /></li>
              <li><input type="password" id="password" class="editbox radius5" placeholder="密码" value="" /></li>
              <li><input type="password" id="re_password" class="editbox radius5" placeholder="确认密码" value="" /></li>
              <li><input type="button" class="button button-fill  button-big" onclick="regist()" value="注册" /></li>
            </ul>
          </form>
        </div>
    </div>
</div>
<div id="img_tmp" style="display: none;">
    <li class="img">
        <a href="#"><i class="iconfont">&#xe6d3;</i></a>
        <img src="" id="img_src"/>
        <input type="hidden" class="imgs" id="img_src_hidden" value="imgSrc"/>
    </li>
</div>
<script type="text/javascript">
    $(function () {
        $.init();

    })

    function regist() {
//        var ua = navigator.userAgent.toLowerCase();
//        if(ua.match(/MicroMessenger/i) != "micromessenger") {
//            $.alert('请登录微信再进行注册!');
//            return false;
//        }
        var mercahntName = $('#mercahnt_name').val();
        var person = $('#mercahnt_person').val();
        var phone = $('#person_phone').val();
        var loginName = $('#login_name').val();
        var password = $('#password').val();
        var img_src = $('#img_src_hidden').val();

        var realName = $('#real_name').val();
        var weChat = $('#we_chat').val();
        var teacher = $('#teacher').val();
        var team = $('#team').val();
        var classes = $('#classes').val();
        var address = $('#address').val();


        if (img_src == null || img_src == '') {
            $.toast('请上传商户Logo!');
            return;
        }
        if(mercahntName == null || mercahntName == ''){
            $.toast('请填写商户名称!');
            return ;
        }

        if(person == null || person == ''){
            $.toast('请填写联系人名称!');
            return ;
        }

        if(phone == null || phone == ''){
            $.toast('请填写联系人手机号!');
            return ;
        }

        if(address == null || address == ''){
            $.toast('请填写商户地址!');
            return ;
        }

        if(loginName == null || loginName == '' || loginName == undefined){
            $.toast('请填写登录名!');
            return ;
        }

        if(password == null || password == '' || password == undefined){
            $.toast('请填写登录密码!');
            return ;
        }

        if(password.length < 6 ){
            $.toast('密码长度不能小于六位!');
            return ;
        }

        var re_password = $('#re_password').val();

        if(re_password == null || re_password == '' || re_password == undefined){
            $.toast('请确认登录密码!');
            return ;
        }

        if(password != re_password){
            $.toast('两次密码输入不一致,请重新输入密码!');
            $('#password').val('');
            $('#re_password').val('');
            return;
        }
        if(weChat == null || weChat == '' || weChat == undefined){
            $.toast('请填写微信号!');
            return ;
        }
        if(realName == null || realName == '' || realName == undefined){
            $.toast('请填写真实姓名!');
            return ;
        }
        if(classes == null || classes == '' || classes == undefined){
            $.toast('请填写班级!');
            return ;
        }


        $.getJSON('/regist/save',{mercahntName:mercahntName ,person:person , phone:phone ,
            loginName: loginName , password:password,imgSrc:img_src,
             realName:realName,
             weChat:weChat,
             teacher:teacher,
             team:team,
             classes:classes,
            address:address
        },function (data) {
            if(data.success){
                $.toast('注册成功!');
                window.location.href = '/';
            }else {
                $.toast(data.msg);
            }

        })

    }

</script>
</body>
